﻿<views:RibbonWindowView x:TypeArguments="viewModels:MainViewModel" x:Class="BattleFury.Server.Wpf.Views.MainView"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:converters="clr-namespace:BattleFury.Server.Wpf.Core.Converters"
		xmlns:avalonDock="clr-namespace:Xceed.Wpf.AvalonDock;assembly=Xceed.Wpf.AvalonDock"
		xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
		xmlns:xctk="clr-namespace:Xceed.Wpf.Toolkit.PropertyGrid;assembly=Xceed.Wpf.Toolkit"
		xmlns:selectors="clr-namespace:BattleFury.Server.Wpf.Core.Selectors"
		xmlns:views="clr-namespace:BattleFury.Server.Wpf.Core.Views"
		xmlns:viewModels="clr-namespace:BattleFury.Server.Wpf.ViewModels"
		xmlns:selectors2="clr-namespace:BattleFury.Server.Wpf.Core.Selectors"
		Title="Battle Fury Server" Width="1024" Height="768" WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <converters:ActiveDocumentConverter x:Key="ActiveDocumentConverter"/>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition Height="32"/>
        </Grid.RowDefinitions>

        <Ribbon Grid.Row="0">
            <Ribbon.HelpPaneContent>
                <RibbonButton SmallImageSource="/Resources\help.png" />
            </Ribbon.HelpPaneContent>

            <Ribbon.QuickAccessToolBar>
                <RibbonQuickAccessToolBar>
                    <RibbonButton SmallImageSource="/Resources\Config.png" ToolTip="Settings" Command="{Binding SettingsCommand}"/>
                </RibbonQuickAccessToolBar>
            </Ribbon.QuickAccessToolBar>

            <Ribbon.ApplicationMenu>
                <RibbonApplicationMenu KeyTip="F">
                    <RibbonApplicationMenuItem Header="Settings" ImageSource="/Resources\Config.png" Command="{Binding SettingsCommand}"/>
                    <RibbonApplicationMenuItem Header="Exit" ImageSource="/Resources\Exit.png" Command="{Binding ExitCommand}"/>
                </RibbonApplicationMenu>
            </Ribbon.ApplicationMenu>

            <RibbonTab Header="Home" KeyTip="H" >
                <RibbonGroup>
                    <RibbonGroup.Header>
                        <TextBlock Text="Status" Foreground="Black"/>
                    </RibbonGroup.Header>
                    <Image Source="{Binding ServerStatusImage, Mode=TwoWay}" Width="64" Height="64"/>
                </RibbonGroup>
                <RibbonGroup>
                    <RibbonGroup.Header>
                        <TextBlock Text="Server Actions" Foreground="Black"/>
                    </RibbonGroup.Header>
                    <RibbonButton LargeImageSource="/Resources\network-connect-3.png" Label="Connect" Command="{Binding ConnectCommand}"/>
                    <RibbonButton LargeImageSource="/Resources\network-disconnect-3.png" Label="Disconnect" Command="{Binding DisconnectCommand}"/>
                    <RibbonButton LargeImageSource="/Resources\games-config-options.png" Label="Settings" Command="{Binding SettingsCommand}"/>
                </RibbonGroup>
                <RibbonGroup>
                    <RibbonGroup.Header>
                        <TextBlock Text="Map Actions" Foreground="Black"/>
                    </RibbonGroup.Header>
                    <RibbonButton LargeImageSource="/Resources\games-config-board.png" Label="Create Blank Map" Command="{Binding CreateBlankMapCommand}"/>
                </RibbonGroup>
            </RibbonTab>
        </Ribbon>

        <avalonDock:DockingManager x:Name="dockingManager" Grid.Row="1"
									DocumentsSource="{Binding Tabs, Mode=TwoWay}"
									ActiveContent="{Binding ActiveTab, Mode=TwoWay, Converter={StaticResource ActiveDocumentConverter}}" Margin="0,10,0,0"
									>
            <avalonDock:DockingManager.Theme>
                <xcad:VS2010Theme/>
            </avalonDock:DockingManager.Theme>

            <avalonDock:DockingManager.LayoutItemTemplateSelector>
                <selectors2:PanesTemplateSelector>
                    <selectors2:PanesTemplateSelector.ServerViewTemplate>
                        <DataTemplate>
                            <Border Background="#CED4DF" BorderBrush="#B9C9DA" BorderThickness="1" CornerRadius="4" Margin="4,0,4,0" Padding="4">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="24"/>
                                        <!-- Server Name -->
                                        <RowDefinition Height="24"/>
                                        <!-- Port Number -->
                                        <RowDefinition Height="24"/>
                                        <!-- MOTD -->
                                        <RowDefinition/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="8"/>
                                        <ColumnDefinition/>
                                        <ColumnDefinition/>
                                        <ColumnDefinition/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Row="0" Grid.Column="1" Text="Server Name:"/>
                                    <TextBox Grid.Row="0" Grid.Column="2" Text="{Binding Name, Mode=TwoWay}" IsEnabled="{Binding IsEnabled}"/>

                                    <TextBlock Grid.Row="1" Grid.Column="1" Text="Port: "/>
                                    <TextBox Grid.Row="1" Grid.Column="2" Text="{Binding Port, Mode=TwoWay}" IsEnabled="{Binding IsEnabled}"/>

                                    <TextBlock Grid.Row="2" Grid.Column="1" Text="Message of the Day: "/>
                                    <TextBox Grid.Row="2" Grid.Column="2" Text="{Binding MOTD, Mode=TwoWay}" IsEnabled="{Binding IsEnabled}"/>
                                </Grid>
                            </Border>
                        </DataTemplate>
                    </selectors2:PanesTemplateSelector.ServerViewTemplate>
                </selectors2:PanesTemplateSelector>
            </avalonDock:DockingManager.LayoutItemTemplateSelector>

            <avalonDock:DockingManager.LayoutItemContainerStyleSelector>
                <selectors:PanesStyleSelector>
                    <selectors:PanesStyleSelector.ServerStyle>
                        <Style TargetType="{x:Type xcad:LayoutItem}">
                            <Setter Property="Title" Value="{Binding Model.Name}"/>
                            <Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}"/>
                            <!--<Setter Property="IconSource" Value="{Binding Model.IconSource}"/>-->
                            <!--<Setter Property="ContentId" Value="{Binding Model.ContentId}"/>-->
                        </Style>
                    </selectors:PanesStyleSelector.ServerStyle>
                </selectors:PanesStyleSelector>
            </avalonDock:DockingManager.LayoutItemContainerStyleSelector>

            <xcad:LayoutRoot>
                <xcad:LayoutPanel Orientation="Horizontal">
                    <xcad:LayoutDocumentPane />

                    <xcad:LayoutAnchorablePaneGroup DockWidth="256" Orientation="Vertical">
                        <xcad:LayoutAnchorablePane>
                            <xcad:LayoutAnchorable Title="Data Stream">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="24"/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="64"/>
                                        <ColumnDefinition/>
                                    </Grid.ColumnDefinitions>
                                    <ListView Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemsSource="{Binding DataStream, Mode=TwoWay}" SelectedIndex="{Binding DataStreamSelectedIndex, Mode=TwoWay}" SelectionChanged="DataStreamSelectionChanged">
                                        <ListView.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding RawData, Mode=TwoWay}"/>
                                            </DataTemplate>
                                        </ListView.ItemTemplate>
                                    </ListView>
                                </Grid>
                            </xcad:LayoutAnchorable>
                        </xcad:LayoutAnchorablePane>
                        <xcad:LayoutAnchorablePane>
                            <xcad:LayoutAnchorable Title="Connections">
                                <ListView Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemsSource="{Binding Connections, Mode=TwoWay}">
                                    <ListView.ItemTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Id, Mode=TwoWay}"/>
                                        </DataTemplate>
                                    </ListView.ItemTemplate>
                                </ListView>
                            </xcad:LayoutAnchorable>
                        </xcad:LayoutAnchorablePane>
                    </xcad:LayoutAnchorablePaneGroup>
                </xcad:LayoutPanel>

            </xcad:LayoutRoot>
        </avalonDock:DockingManager>

        <StatusBar Grid.Row="2">
            <TextBlock Text="{Binding Status, Mode=TwoWay}"/>
        </StatusBar>

    </Grid>
</views:RibbonWindowView>
